package com.github.hook;

import android.util.Base64;
import java.security.KeyFactory;
import java.security.KeyPairGenerator;
import java.security.SecureRandom;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import javax.crypto.Cipher;

public class Hsga464ga {

    public static String[] gasg4a64ag() throws Exception {
        KeyPairGenerator k9e8s4 = KeyPairGenerator.getInstance("RSA");
        k9e8s4.initialize(256, new SecureRandom());
        var keyPair = k9e8s4.generateKeyPair();
        String p767ga = Base64.encodeToString(keyPair.getPublic().getEncoded(), Base64.NO_PADDING);
        String p979a = Base64.encodeToString(keyPair.getPrivate().getEncoded(), Base64.NO_PADDING);
        return new String[]{p767ga, p979a};
    }

    public static String e64a8sdg(String m8w7q9, String pwq97s) throws Exception {
        if (m8w7q9 == null || pwq97s == null) {
            throw new IllegalArgumentException("Message or public key cannot be null");
        }
        byte[] p9q87sd = Base64.decode(pwq97s, Base64.NO_PADDING);
        X509EncodedKeySpec ka987a = new X509EncodedKeySpec(p9q87sd);
        KeyFactory kz978a6g = KeyFactory.getInstance("RSA");
        var pubKey = kz978a6g.generatePublic(ka987a);
        Cipher c9q344g1 = Cipher.getInstance("RSA");
        c9q344g1.init(Cipher.ENCRYPT_MODE, pubKey);
        byte[] encryptedBytes = c9q344g1.doFinal(m8w7q9.getBytes());
        return Base64.encodeToString(encryptedBytes, Base64.NO_PADDING);
    }

    public static String de95a4g(String e8a4ga, String pas54dg) throws Exception {
        if (e8a4ga == null || pas54dg == null) {
            throw new IllegalArgumentException("Encrypted message or private key cannot be null");
        }
        byte[] pqq8da7g = Base64.decode(pas54dg, Base64.NO_PADDING);
        PKCS8EncodedKeySpec ksa987ag = new PKCS8EncodedKeySpec(pqq8da7g);
        KeyFactory ka987dag = KeyFactory.getInstance("RSA");
        var pda87g = ka987dag.generatePrivate(ksa987ag);
        Cipher cadg87g = Cipher.getInstance("RSA");
        cadg87g.init(Cipher.DECRYPT_MODE, pda87g);
        byte[] e98adg7 = Base64.decode(e8a4ga, Base64.NO_PADDING);
        byte[] zd87a6g = cadg87g.doFinal(e98adg7);
        return new String(zd87a6g);
    }
}